package com.example.androidmainshixun.view;

import android.view.View;
import android.widget.TextView;

import com.example.androidmainshixun.R;
import com.example.androidmainshixun.base.BaseFragment;
import com.example.androidmainshixun.database.DBHelper;
import com.example.androidmainshixun.entity.User;
import com.example.androidmainshixun.utils.SpUtils;

public class MineActivityFragment extends BaseFragment implements View.OnClickListener{

    private TextView musername_now;
    private TextView muserid_now;
    private SpUtils mSpUtils;
    @Override
    public void onClick(View v) {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mine_fragment;
    }

    @Override
    protected void initView() {
        musername_now = mView.findViewById(R.id.username_now);
        muserid_now=mView.findViewById(R.id.userid_now);
        mSpUtils = new SpUtils(mContext);
        //检测登录状态
        int loginId = mSpUtils.getInt(SpUtils.LOGIN_KEY, -1);
        if (loginId >= 0) {
            //根据id查询当前登录学生的信息
            User user = DBHelper.getInstance(mContext).getUserById(loginId);
            if (user != null) {
                //将当前登录的学生信息显示在界面上
                musername_now.setText(user.getUsername());
                muserid_now.setText(String.valueOf(user.getUserid()));
            }
        }
    }

    @Override
    protected void initListener() {

    }
}
